package com.cloudsigns.factorymanager2.project.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.project.adapter.EngineeringOrderListAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tony on 2017/12/12.
 */

public class EngineeringOrderListActivity extends Activity implements View.OnClickListener {

    private ImageView img_back;
    private TextView tv_title;
    private TextView btn_delete;
    private ListView lv;
    private EngineeringOrderListAdapter adapter;
    private List<OrderParentBean> designTypeBeanList = new ArrayList<>();
    private String TAG = EngineeringOrderListActivity.class.getSimpleName();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.layout_engineering_order_list);

        init();
    }

    private void init() {
        img_back = findViewById(R.id.img_back);
        tv_title = findViewById(R.id.tv_title);
        btn_delete = findViewById(R.id.btn_delete);
        lv = findViewById(R.id.lv);

        tv_title.setText(getResources().getText(R.string.engineering_work_order));
        img_back.setOnClickListener(this);
        btn_delete.setOnClickListener(this);

//        designTypeBeanList.add(new EngineeringOrderBean(ConstantUtil.ENGINEERING_INSTALLATION_ORDER, "宝安区肯德基", "宝安区西乡", "2017-01-30", ConstantUtil.WAITING_FOR_RECEIVE));
//        designTypeBeanList.add(new EngineeringOrderBean(ConstantUtil.ENGINEERING_CONSTRUCT_ORDER, "福田区肯德基", "福田区", "2017-02-30", ConstantUtil.BACK));
//        designTypeBeanList.add(new EngineeringOrderBean(ConstantUtil.ENGINEERING_BATCH_INSTALLATION_ORDER, "南山区肯德基", "福田区", "2017-03-30", ConstantUtil.RECEIVED));
        adapter = new EngineeringOrderListAdapter(this, TAG);
        adapter.setData(designTypeBeanList);
        lv.setAdapter(adapter);

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                Intent mIntent;
                OrderParentBean order = designTypeBeanList.get(position);
//                if (order.getEngineeringType().equals(ConstantUtil.ENGINEERING_INSTALLATION_ORDER)) {
//                    mIntent = new Intent(EngineeringOrderListActivity.this, EngineeringInstallationOrderDetailActivity.class);
//                    startActivity(mIntent);
//
//                } else if (order.getEngineeringType().equals(ConstantUtil.ENGINEERING_CONSTRUCT_ORDER)) {
//                    mIntent = new Intent(EngineeringOrderListActivity.this, EngineeringConstructionOrderDetailActivity.class);
//                    startActivity(mIntent);
//
//                } else if (order.getEngineeringType().equals(ConstantUtil.ENGINEERING_BATCH_INSTALLATION_ORDER)) {
//                    mIntent = new Intent(EngineeringOrderListActivity.this, BatchInstallationOrderDetailActivity.class);
//                    startActivity(mIntent);
//
//                }
            }
        });
    }


    @Override
    public void onClick(View view) {
        TextView tv;
        Intent mIntent;
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;

        }
    }

}
